package org.onepiece.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onepiece.admin.common.config.nacos.OnepieceConfig;
import org.onepiece.admin.common.config.yaml.AllocationRuleScorePropertiesComponent;
import org.onepiece.admin.common.utils.CommonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 *
 * @author zhujianke@gaodun.com
 * @since 2022/8/21 14:47
 */
@Slf4j
@Api(tags = {"IndexController系统入口控制器"})
@RequestMapping(value = "/index")
@AllArgsConstructor
@RestController
public class IndexController {

    private final OnepieceConfig onepieceConfig;
    private final AllocationRuleScorePropertiesComponent allocationRuleScorePropertiesComponent;

    @ApiOperation("测试入口方法")
    @GetMapping("/demo")
    public CommonResult<Map<String, Integer>> demo() {
        String username = onepieceConfig.getUsername();
        log.debug("IndexController#demo username:{}", username);
        Map<String, Integer> map = allocationRuleScorePropertiesComponent.getMap();
        return CommonResult.ok(map);
    }
}
